<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>闭包内存泄露的解决方法</title>
</head>
<body>
    <div des="xiasnn">xiasnn</div>
    <div des="xiaxia">xiaxia</div>
    <script>
        let divs = document.querySelectorAll('div');
        divs.forEach(item => {
            // 找到div的des
            let des = item.getAttribute("des");
            item.addEventListener('click',function(){
                console.log(des);
                console.log(item);  //null
            });
            // item用完之后置为空，释放掉
            item = null;
        })
    </script>
</body>
</html>